package com.lepinwenhua.independent_edit_text;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import java.util.HashMap;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

    private IndependentEditTextUtil independentEditTextUtil;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        View mView = View.inflate(this, R.layout.activity_main, null);
        setContentView(mView);


        independentEditTextUtil = new IndependentEditTextUtil(this, mView);
        independentEditTextUtil.startResendTimer();//倒计时

        independentEditTextUtil.setOnEditTextClick(new IndependentEditTextUtil.OnEditTextClick() {
            @Override
            public void onEditTextClick(String value) {
                Toast.makeText(MainActivity.this,value,Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onResendTimeClick() {
                //倒计时结束
                Toast.makeText(MainActivity.this,"重新发送验证码",Toast.LENGTH_SHORT).show();
                independentEditTextUtil.resendTime(59);
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (independentEditTextUtil!=null){
            independentEditTextUtil.onDestroy();
        }
        if (independentEditTextUtil!=null){
            independentEditTextUtil=null;
        }
    }

}